
<?php include './application/views/top.php'; ?>
<script src="/static/js/gsdai.js"></script>
<script src="/static/js/ajaxfileupload.js"></script>
<script src="/static/js/My97DatePicker/WdatePicker.js"></script>
<script src="/static/js/formCheck.js"></script>

<div class="clear"></div>
<div class="user_bottom all"></div>
<div class="clear h50"></div>
<div class="layout uc">
	<?php include './application/views/user/left.php'; ?>
	<div class="right">
		<div class="menu_list"><?php include './application/views/user/menu.php'; ?></div>
        <div class="cont">
        	<form id="borrowautoForm" name="borrowautoForm">
            <input type="hidden" id="id" name="id" value="<?php echo $borrow_auto_obj['id'];?>">
            <dl class="line">
            	<dt>是否启用：</dt>
                <dd>
				<input type="radio" id="fstatus" name="fstatus" value="1" <?php if($borrow_auto_obj['fstatus'] == 1){?>checked="checked"<?php }?>><label>是</label>
				<input type="radio" id="fstatus" name="fstatus" value="0"><label>否</label>
                </dd>
            </dl>
            <dl class="line">
            	<dt>按金额：</dt>
                <dd>
					<input type="radio" id="tender_type" name="tender_type" value="1" <?php if($borrow_auto_obj['tender_type'] == 1){?>checked="checked"<?php }?>>
					<label>最多</label><input name="tender_account"  class="pubinput" type="text" maxlength="6" id="tender_account"  style="width:80px;" value="<?php if($borrow_auto_obj['tender_type'] == 1){?><?php echo $borrow_auto_obj["tender_account"];?><?php }?>" /><span>元(不能大于30万元)</span>
					<label>最少</label><input name="tender_account1"  class="pubinput" type="text" maxlength="6" id="tender_account1"  style="width:80px;" value="<?php if($borrow_auto_obj['tender_type'] == 1){?><?php echo $borrow_auto_obj["tender_account1"];?><?php }?>" /><span>元(不能小于100元)</span>
                </dd>
            </dl>
            <dl class="line">
            	<dt>还款方式：</dt>
                <dd>
			            	<input type="checkbox" id="borrow_style_status" name="borrow_style_status" value="1" <?php if($borrow_auto_obj['borrow_style_status'] == 1){?>checked="checked"<?php }?>><label>是否启用</label>
							<select id="borrow_style" name="borrow_style" class="pubinput">
								<?php foreach($borrow_style as $key=>$value){?>
								<option value="<?php echo $key;?>" <?php if($borrow_auto_obj['borrow_style'] == $key){?>selected="selected"<?php }?>><?php echo $value;?></option>
								<?php }?>
							</select>
                </dd>
            </dl>
            <dl class="line">
            	<dt>借款期限：</dt>
                <dd>
			            	<input type="checkbox" id="timelimit_status" name="timelimit_status" value="1" <?php if($borrow_auto_obj['timelimit_status'] == 1){?>checked="checked"<?php }?>>是否启用
							<select id="timelimit_month_first" name="timelimit_month_first" class="pubinput">
								<?php foreach($borrow_time_limit as $key=>$value){?>
								<option value="<?php echo $key;?>" <?php if($borrow_auto_obj['timelimit_month_first'] == $key){?>selected="selected"<?php }?>><?php echo $value;?></option>
								<?php }?>
							</select>-
							<select id="timelimit_month_last" name="timelimit_month_last" class="pubinput">
								<?php foreach($borrow_time_limit as $key=>$value){?>
								<option value="<?php echo $key;?>" <?php if($borrow_auto_obj['timelimit_month_last'] == $key){?>selected="selected"<?php }?>><?php echo $value;?></option>
								<?php }?>
							</select>
                </dd>
            </dl>
            <dl class="line">
            	<dt>利率选项：</dt>
                <dd>
			            	<input type="checkbox" id="apr_status" name="apr_status" value="1" <?php if($borrow_auto_obj['apr_status'] == 1){?>checked="checked"<?php }?>>是否启用
							<select id="apr_first" name="apr_first" class="pubinput">
								<?php for($i = 1; $i < 24; $i++){?>
								<option value="<?php echo $i;?>" <?php if($borrow_auto_obj['apr_first'] == $i){?>selected="selected"<?php }?>><?php echo $i;?>%</option>
								<?php }?>
							</select>-
							<select id="apr_last" name="apr_last" class="pubinput">
								<?php for($i = 5; $i < 25; $i++){?>
								<option value="<?php echo $i;?>" <?php if($borrow_auto_obj['apr_last'] == $i){?>selected="selected"<?php }?>><?php echo $i;?>%</option>
								<?php }?>
							</select>
                </dd>
            </dl>
            <dl class="line">
            	<dt>奖励选项：</dt>
                <dd>
			            	<input type="checkbox" id="award_status" name="award_status" value="1" <?php if($borrow_auto_obj['award_status'] == 1){?>checked="checked"<?php }?>>是否启用
							<select id="award_first" name="award_first" class="pubinput">
								<?php for($i = 1; $i < 15; $i++){?>
								<option value="<?php echo $i/10;?>" <?php if($borrow_auto_obj['award_first'] == $i/10){?>selected="selected"<?php }?>><?php echo $i/10;?>%</option>
							<?php }?>
							</select>-
							<select id="award_last" name="award_last" class="pubinput">
								<?php for($i = 1; $i < 15; $i++){?>
								<option value="<?php echo $i/10;?>"  <?php if($borrow_auto_obj['award_last'] == $i/10){?>selected="selected"<?php }?> ><?php echo $i/10;?>%</option>
								<?php }?>
								<option value="2" <?php if($borrow_auto_obj['award_last'] == 2){?>selected="selected"<?php }?> >2%</option>
								<option value="3" <?php if($borrow_auto_obj['award_last'] == 3){?>selected="selected"<?php }?> >3%</option>
								<option value="4" <?php if($borrow_auto_obj['award_last'] == 4){?>selected="selected"<?php }?> >4%</option>
								<option value="5" <?php if($borrow_auto_obj['award_last'] == 5){?>selected="selected"<?php }?> >5%</option>
								<option value="6" <?php if($borrow_auto_obj['award_last'] == 6){?>selected="selected"<?php }?> >6%</option>
								<option value="7" <?php if($borrow_auto_obj['award_last'] == 7){?>selected="selected"<?php }?> >7%</option>
								<option value="8" <?php if($borrow_auto_obj['award_last'] == 8){?>selected="selected"<?php }?> >8%</option>
								<option value="9" <?php if($borrow_auto_obj['award_last'] == 9){?>selected="selected"<?php }?> >9%</option>
								<option value="10" <?php if($borrow_auto_obj['award_last'] == 10){?>selected="selected"<?php }?> >10%</option>
							</select>
                </dd>
            </dl>
            <div class="cb"><input class="button" type="submit" value="确认修改" onclick="borrowautoSubmit();" /></div>
            </form>
        </div>
	</div>
</div>
<div class="clear h50"></div>
<?php include "./application/views/footer.php";?>
<script type="text/javascript">
function borrowautoSubmit(){
	var options = {
		url : '/borrowauto/edit/',
		clearForm :true,
		resetForm :true,
		beforeSubmit:  checkForm,
		dataType: "json",
		type:"post",
		success : function(ret) {
			if(ret.msg==''){
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}},
					close: function() {
						location=ret.url;
					}
				}); 
				$("#msg").html("操作成功");
			}else{
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}},
					close: function() {
						location=ret.url;
					}
				}); 
				$("#msg").html(ret.msg);
			}
		}
	};
	$("#borrowautoForm").ajaxSubmit(options);
	return false;
}

function checkForm(){
	var err = '';
	if($('input[name="tender_type"]:checked').val() == 1){
		if(IsDouble($('#tender_account').val())==false){
			err = '请填写有效的最多投资金额';
		}else if($('#tender_account').val()>300000){
			err = '最多投资金额最高300000';
		}else if(IsDouble($('#tender_account1').val())==false){
			err = '请填写有效的最少投标金额';
		}
	}
	
	if($('input[name="tender_type"]:checked').val() == 2){
		if(IsDouble($('#tender_scale').val())==false){
			err = '请填写有效的投标比例';
		}
	}
	
	if(err==''){
		return true;
	}else{
		$('#dialog').dialog({
			modal:true, //蒙层（弹出会影响页面大小）
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}}
		}); 
		$("#msg").html(err);
		return false;
	}
}
</script>